package com.wondream.myframework.design_pattern.factory;

public class Creator implements ICreator {

    private final static Creator INSTANCE = new Creator();

    private Creator(){}

    public static Creator getInstance() {
        return INSTANCE;
    }

    @Override
    public <T extends IProduct> T factory(Class<T> clazz) {
        IProduct product = null;
        try {
            product = (IProduct) Class.forName(clazz.getName()).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (T) product;
    }
}
